<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .con{
            width: 500px;
            display:flex;
            justify-content: space-between;
        }
        .con div{
            width: 100px;
            height: 100px;
            background-color: lightblue;
        }
    </style>
</head>
<body>
    <button>点击变红</button>
    <div class="con">
        <div></div>
        <div></div>
        <div></div>
    </div>
    <script>
        var btn = document.querySelector('button');
        var lis = document.querySelectorAll('.con div');
          btn.onclick = function(){
            for(var i = 0 ;i< lis.length;i++){
               lis[i].style.backgroundColor = "red";
            }
        }
    </script>
</body>
</html>